package com.njh.charges.controller.apis;

import com.alipay.api.AlipayApiException;
import com.hos.vo.Result;
import com.njh.charges.service.PayService;
import com.njh.charges.vo.AliPaySync;
import com.njh.charges.vo.AlipayBean;
import com.njh.charges.vo.OrderChargeDtoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/charges/api/pay")
@Api(tags = "支付宝沙箱支付相关接口")
public class PayController {

    @Resource
    private PayService payService;

    /**
     * 阿里支付
     * @param orderChargeDtoVo
     * @return
     * @throws AlipayApiException
     */
    @PostMapping("/alipay")
    @ApiOperation("支付宝支付")
    public Result alipay(@RequestBody OrderChargeDtoVo orderChargeDtoVo) throws AlipayApiException {

        Object pay = payService.pay(orderChargeDtoVo);
        return new Result(200,"跳转支付页面",pay);
    }

    @GetMapping("/queryOrderChargeOrderId/{orderId}")
    @ResponseBody
    public Result AlipayTrade(@PathVariable String orderId) throws AlipayApiException {
        return payService.AlipayTrade(orderId);
    }

    @GetMapping("/toPayOrderWithZfb/{orderId}")
    @ResponseBody
    public Result toPayOrderWithZfb(@PathVariable String orderId) {

        Object pay = payService.toPayOrderWithZfb(orderId);
        return new Result(200,"跳转支付页面",pay);
    }



}

